package org.anddev.andengine.extension.svg.util.render;
/**
 * @author Eric Depta
 * @since 01:14:00 - 28.02.2011
 */
//import org.anddev.andengine.entity.primitive.Line;
import org.anddev.andengine.entity.shape.Shape;
import org.anddev.andengine.extension.svg.util.primitives.AntiAliasLine;

import com.badlogic.gdx.math.Vector2;

public final class Render {
	
	public static final void lineRender(final Vector2[] pVertices, final Shape pShape, final float[] pColor, final float pAlpha, final float pLWidth, final boolean pAntiAlias, final boolean pClose){
		AntiAliasLine line = null;
		for(int i=1;i<pVertices.length;i++){
			//TODO half stroke width in booth directions add
			// linewidth depending on scaling
			line = new AntiAliasLine(pVertices[i-1].x - pShape.getX(), pVertices[i-1].y - pShape.getY(), pVertices[i].x - pShape.getX(), pVertices[i].y - pShape.getY(), pLWidth);
			line.setAntiAlias(pAntiAlias);
			line.setColor(pColor[0], pColor[1], pColor[2], pAlpha);
			pShape.attachChild(line);
		}
		if(pClose){
			line = new AntiAliasLine(pVertices[pVertices.length-1].x - pShape.getX(), pVertices[pVertices.length-1].y - pShape.getY(), pVertices[0].x - pShape.getX(), pVertices[0].y - pShape.getY(), pLWidth);
			line.setAntiAlias(pAntiAlias);
			line.setColor(pColor[0], pColor[1], pColor[2], pAlpha);
			pShape.attachChild(line);
		}
		
	}
	
	public static final void lineRenderRel(final Vector2[] pVertices, final Shape pShape, final float[] pColor, final float pAlpha, final float pLWidth, final boolean pAntiAlias, final boolean pClose){
		AntiAliasLine line = null;
		for(int i=1;i<pVertices.length;i++){
			//TODO half stroke width in booth directions add
			// linewidth depending on scaling
			line = new AntiAliasLine(pVertices[i-1].x , pVertices[i-1].y , pVertices[i].x , pVertices[i].y , pLWidth);
			line.setAntiAlias(pAntiAlias);
			line.setColor(pColor[0], pColor[1], pColor[2], pAlpha);
			pShape.attachChild(line);
		}
		if(pClose){
			line = new AntiAliasLine(pVertices[pVertices.length-1].x , pVertices[pVertices.length-1].y , pVertices[0].x , pVertices[0].y , pLWidth);
			line.setAntiAlias(pAntiAlias);
			line.setColor(pColor[0], pColor[1], pColor[2], pAlpha);
			pShape.attachChild(line);
		}
		
	}
	
}
